const range = {
    from: 2,
    to: 5,
};

range[Symbol.iterator] = function () {
    return {
        current: this.from,
        last: this.to,
        next() {
            if (this.current <= this.last) {
                return { done: false, value: this.current++ };
            } else {
                return { done: true };
            }
        },
    };
};

for (let n of range) {
    console.log(n);
}

const array = Array.from(range);
console.log('array:', array);
